package com.xsj.dorado.sample.service;

import java.util.Collection;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.xsj.dorado.sample.dao.SlCompanyDao;
import com.xsj.dorado.sample.entity.SlCompany;

@Component
public class CompanyService{ 
    @Resource
    private SlCompanyDao slcompanyDao;
     
    @DataProvider 
    public Collection<SlCompany> getCompanys(){
        return slcompanyDao.getAll();
    }
    
    @DataProvider
    public SlCompany getCompany(){
        List<SlCompany> list = slcompanyDao.getAll();
        for(SlCompany company:list){
            return company;
        }
        return null;
    }
    
    @DataResolver
    @Transactional
    public void saveCompanys(Collection<SlCompany> slcompanys){
        slcompanyDao.persistEntities(slcompanys);
    }
    
    @DataResolver
    @Transactional
    public void saveCompany(SlCompany slcompany){
        slcompanyDao.persistEntity(slcompany);
    }
} 